<template>
  <div>
    <!-- 卡片顶部输入框、查询、添加按钮 -->
    <el-form :inline="true">
      <el-form-item>
        <el-input
          v-model="operateRequest.username"
          placeholder="请输入标签码"
          clearable
        />
      </el-form-item>
			<el-form-item>
        <el-input
          v-model="operateRequest.username"
          placeholder="请输入产品状态"
          clearable
        />
      </el-form-item>
			<el-form-item>
        <el-input
          v-model="operateRequest.username"
          placeholder="请输入产品型号"
          clearable
        />
      </el-form-item>
      <el-form-item>
        <div class="demo-datetime-picker">
          <div class="block">
            <el-date-picker
              v-model="time"
              type="datetimerange"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              format="YYYY-MM-DD HH:mm:ss"
              value-format="YYYY-MM-DD HH:mm:ss"
            />
          </div>
        </div>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="search" icon="Search">查询</el-button>
				<el-button type="primary" @click="search" icon="Edit">下载</el-button>
      </el-form-item>
    </el-form>
    <!-- 表格组件：用于展示用户信息 -->
    <el-table
      :data="runLogArr"
      :header-cell-style="{ background: '#6A9BEB', color: '#fff' }"
    >
		<el-table-column
        label="扫码时间"
        align="center"
        prop="userName"
        width="80"
      ></el-table-column>
      <el-table-column
        label="公轴二维码"
        align="center"
        prop="userName"
        width="80"
      ></el-table-column>
      <el-table-column
        label="公轴节叉压装压力最大值"
        align="center"
        prop="date"
      ></el-table-column>
      <el-table-column
        label="公轴节叉压装最终位移"
        align="center"
        prop="ip"
      ></el-table-column>
      <el-table-column
        label="公轴节叉压装结果OK/NG判定"
        align="center"
        prop="type"
      ></el-table-column>
      <el-table-column
        label="公轴点铆压力最大值"
        align="center"
        prop="content"
      ></el-table-column>
      <el-table-column
        label="公轴点铆最终位移"
        align="center"
        prop="comment"
        show-overflow-tooltip
      ></el-table-column>
			<el-table-column
        label="公轴点铆结果OK/NG判定"
        align="center"
        prop="comment"
        show-overflow-tooltip
      ></el-table-column>
			<el-table-column
        label="公轴铆口OK/NG判定"
        align="center"
        prop="comment"
        show-overflow-tooltip
      ></el-table-column>
			<el-table-column
        label="小转向批次号"
        align="center"
        prop="comment"
        show-overflow-tooltip
      ></el-table-column>
    </el-table>
    <!-- 分页器组件 -->
    <el-pagination
      @size-change="sizeChange"
      @current-change="getOperateInfo"
      v-model:current-page="operateRequest.pageNum"
      v-model:page-size="operateRequest.pageSize"
      :page-sizes="[10, 20, 50, 100]"
      :background="true"
      layout="prev,pager,next,jumper,->,sizes,total"
      :total="total"
    />
  </div>
</template>
<script setup lang="ts">
import { ref, onMounted, reactive } from 'vue';

//存储时间
let time = ref<any>([]);
//请求全部操作日志参数
let operateRequest = reactive<any>({
  username: '', //用户名
  beginTime: '', //开始时间
  endingTime: '', //结束时间
  pageNum: 1, //当前页码
  pageSize: 10, // //每一页展示多少条数据
});
//存储已有运行日志数据总数
let total = ref<number>(0);
//存储已有操作日志的数据(Records定义了一个数组，右边括号里面的[]为初始化数组)
let runLogArr = ref<any>([]);
//组件挂载完毕，发请求获取全部的运行日志
onMounted(() => {
  getOperateInfo();
});
const getOperateInfo = async (pager = 1) => {
  operateRequest.pageNum = pager;

  // let result: any = await reqOperate(operateRequest);
  // if (result.code === 200) {
  //   total.value = result.data.total; //存储已有运行日志总个数
  //   runLogArr.value = result.data.records; //存储已有运行日志数据
  // }
};
//当下拉菜单发生变化的时候触发此方法
const sizeChange = () => {
  getOperateInfo();
};
//查询用户
const search = () => {
  operateRequest.beginTime = time.value[0];
  operateRequest.endingTime = time.value[1];
  //根据关键字获取相应的数据
  getOperateInfo();
  //清空数据
  operateRequest.username = '';
  time.value = '';
};
</script>
<style scoped>
.demo-datetime-picker {
  display: flex;
  width: 100%;
  padding: 0;
  flex-wrap: wrap;
  justify-content: space-around;
  align-items: stretch;
}

.demo-datetime-picker .block {
  /* padding: 30px 0; */
  text-align: center;
}

.line {
  width: 1px;
  background-color: var(--el-border-color);
}
</style>
